#define __Outputcpp__

#include "stdafx.h"

#include "output.h"
#pragma warning(disable: 4996)

// Output currently outputs to stdout.
// In the arduino version it outouts to COM1
// It would be a simple matter to redirect the output to a serial port here or to some other output.
// Only two methods need modification.

// Output can be disabled at ceratin levels in the source files
// For example the output is disabled in GET and therefore the Parser 
// Turn on there for debugging


void Output::PushState()
{
	Output::tempEnabled = Output::enabled;
}

void Output::PopState()
{
	Output::enabled = Output::tempEnabled;
}

void Output::Enable()
{
	Output::enabled = true;
}

void Output::Disable()
{
	Output::enabled = false;
}

/// To converrt to serial just change this ONE function, as well as begin
void Output::print(char * strn)
{ 
	if (enabled)
		printf("%s", strn);
}

void Output::println()
{
	Output::print(NL);
}

void Output::println(char * strn)
{
	Output::print(strn);
	Output::println();
}

void Output::printch(char ch)
{
	//printf("%c", ch);
	char strnn[2];
	sprintf(strnn, "%c", ch);
	Output::print(strnn);
}

void Output::printlnch(char ch)
{
	Output::printch(ch);
	Output::println();

}

void Output::print(int num)
{
	//printf("%d", num);
	char strnn[50];
	sprintf( strnn,"%d", num);
	Output::print(strnn);
}

void Output::println(int num)
{
	Output::print(num);
	Output::println();
}

void Output::print_f(float num)
{
	char strnn[50];
	sprintf(strnn, " %.*f", NUM_DECIMAL_DIGITS_TO_DISPLAY, num);
	Output::print(strnn);
}

void Output::println_f(float num)
{
	Output::print_f(num);
	Output::println();
}

//If serial output then open connection here
void Output::begin(int BAUD)
{
	Output::Enable();
}

BOOL Output::available()
{
	return true;
}


#undef __Outputcpp__

